﻿@using Yelper.Web
@model List<Yelp>

@{
    var user = (User)ViewData["user"];
    ViewBag.Title = "@" + user.Username;
    var idols = (List<User>)ViewData["Idols"];
    var groupies = (List<User>)ViewData["Groupies"];
}

<h1>@@@user.Username</h1>

@foreach (Yelp yelp in Model) {
    @Html.Partial("YelpPartial", yelp)
}

@section right {

    <h1>Info</h1>
    @if(user.Bio != null) { @user.Bio.Replace("\n","<br />") }
    @if(user.Website!=null && user.Website != ""){
        <a href="@user.Website">@user.Website</a>
    }
    
    @if (Request.IsAuthenticated && user.Username != Context.User.Identity.Name) {
        bool IsIdol = (bool)ViewData["IsIdol"];
        using (Ajax.BeginForm(new AjaxOptions() {
            LoadingElementId = "GroupieThingLoading",
            Url = Url.Action("ToggleGroupie","Ajax",new { Username = user.Username }),
            UpdateTargetId = "GroupieButton",
            HttpMethod = "Get"
        })) {
        <div id="GroupieButton">
        @if (IsIdol) {
            <input type="submit" value="Stop being a groupie" />
        } else {
            <input type="submit" value="Become a groupie" />
        }
        <div id="GroupieThingLoading" class="hidden">
            <img src="@Url.Content("~/Content/Images/loading.gif")" alt="loading" />        
        </div>
        </div>
        }
    }
    
    <br /><br />
    
    <h1>Idols</h1>
    @Html.Partial("UserIconsPartial", idols)

    <br /><br /><br />

    <h1>Groupies</h1>
    @Html.Partial("UserIconsPartial", groupies)

}